package main

import (
	"fmt"
	"github.com/gomodule/redigo/redis"
)

func main() {
	con, err := redis.Dial("tcp", "127.0.0.1:6379" /*,redis.DialUsername("")*/)
	if err != nil {
		fmt.Println("redis conn error is ", err)
		return
	}
	defer con.Close()
	fmt.Println("redis conn success")
	/*_,err1 := con.Do("HSet","user1","name","zw")
	if err1 != nil {
		fmt.Println("redis HSet error is ",err)
		return
	}
	_,err2 := con.Do("HSet","user1","age",16)
	if err2 != nil {
		fmt.Println("redis HSet error is ",err)
		return
	}

	res,err1 := redis.String(con.Do("HGet","user1","name"))
	if err1 != nil {
		fmt.Println("redis HGet error is ",err)
		return
	}
	fmt.Println("redis Get result is ",res)
	res2,err1 := redis.Int(con.Do("HGet","user1","age"))
	if err1 != nil {
		fmt.Println("redis HGet error is ",err)
		return
	}
	fmt.Println("redis Get result is ",res2)*/

	_, err1 := con.Do("HMSet", "user1", "name", "zw", "age", 10)
	if err1 != nil {
		fmt.Println("redis HSet error is ", err)
		return
	}
	res, err1 := redis.Strings(con.Do("HMGet", "user1", "name", "age"))
	if err1 != nil {
		fmt.Println("redis HGet error is ", err)
		return
	}
	for i, v := range res {
		fmt.Printf("redis Get result is [%v][%v]\n", i, v)
	}

}
